//
//  QJUserDelegateVC.m
//  QuanJieShopProject
//
//  Created by 刘中义 on 2018/2/25.
//  Copyright © 2018年 apple. All rights reserved.
//

#import "QJUserDelegateVC.h"

@interface QJUserDelegateVC ()<UIWebViewDelegate>
@property (nonatomic, strong) UIWebView *webView;

@end

@implementation QJUserDelegateVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.title = @"注册协议";
    UIWebView *webView = [[UIWebView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.view = webView;
    webView.delegate = self;
    NSString *urlString = [NSString stringWithFormat:@"%@%@",kApiPrefix,@"mobile/Article/detail/article_id/1415.html?app=1"];
    
    NSURL *url = [NSURL URLWithString:urlString];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [webView loadRequest:request];
    
}

// 网页开始加载的时候调用
- (void)webViewDidStartLoad:(UIWebView *)webView {
    NSLog(@"webViewDidStartLoad");
    [MBPHUD showHUDWithTitle:@"正在加载中"];
}

// 网页加载完成的时候调用
- (void)webViewDidFinishLoad:(UIWebView *)webView {
    NSLog(@"webViewDidFinishLoad");
    [MBPHUD hideMBPHUD];
}

// 网页加载出错的时候调用
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
    NSLog(@"didFailLoadWithError");
}

// 网页中的每一个请求都会被触发这个方法，返回NO代表不执行这个请求(常用于JS与iOS之间通讯)
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
    NSLog(@"shouldStartLoadWithRequest");
    return YES;
}
@end
